package com.laotou99.wmsjjj.wmsjjj;

import static org.junit.Assert.assertEquals;

import java.util.List;
import java.util.Random;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.classmate.members.RawMethod;
import com.laotou99.wmsjjj.wmsjjj.bean.po.ASNPO;
import com.laotou99.wmsjjj.wmsjjj.bean.vo.ASNDetailVO;
import com.laotou99.wmsjjj.wmsjjj.bean.vo.ASNVO;
import com.laotou99.wmsjjj.wmsjjj.service.ASNService;

@RunWith(SpringRunner.class)
@SpringBootTest
public class WmsjjjASNTests1 {

	@Autowired
	ASNService asnService;

	@Test
	public void contextLoads() {
		System.out.println("first load");}
	
	@Before
	public void before() {
		System.out.println("before");}
	
	@After
	public void after() {
		System.out.println("after()");}
	
	
	
	@Test
	public void test3() {
		System.out.println("test3");
		ASNVO asnvo = new ASNVO();
		asnvo.setStorekey("apple");
		asnvo.setBussNum("00001");
		asnvo.setPkgType("BOX");
		asnvo.setInvoiceNum("A0021");
//		asnService.saveASN(asnvo);
		assertEquals(1+1, 2);
	}
	
	@Test
	public void test4() {
		System.out.println("test4");
		Random r1 = new Random(System.currentTimeMillis());
		
		for(int i1 = 0;i1<10;i1++) {
			ASNDetailVO asnDetailVO = new ASNDetailVO();
			asnDetailVO.setSku("0002");
			asnDetailVO.setSkuCN("iPad 128G");
			asnDetailVO.setSkuEN("iPad 128G");
			asnDetailVO.setLegalUnit("BOX");
			asnDetailVO.setMoqNum(r1.nextInt(100));  
			asnDetailVO.setLocID("A0001");
			//asnService.saveASNDetail(asnDetailVO, 1l);
		}
		assertEquals(1+1, 2);
	}
	
	@Test
	public void test5() {
		System.out.println("test5");
		 
//		List<ASNDetailVO> li1 = 
//			asnService.getASNDetailList(34l);
//		for(ASNDetailVO vo:li1) {
//			System.out.println("ASNDetailVO vo-=>"
//				+JSON.toJSONString(vo));
//			vo.setLocID("A0002");
//			//asnService.updateASNDetail(vo);
//		} 
		assertEquals(1+1, 2);
	}

	@Test
	public void test6() {
		System.out.println("test6=收货操作");
		
//		String str1 = asnService.receiveASN(1l);
//		System.out.println("str1-=>"+str1);
		
		assertEquals(1+1, 2);
	}
	
	@Test
	public void test1() {
		System.out.println("test1");
		List<ASNVO> asnList = asnService.getASNList();
		System.out.println("asnList-=>"
			+JSON.toJSONString(asnList));
		assertEquals(1+1, 2);
	}
	
	@Test
	public void test2() { 
		System.out.println("test2");
		List<ASNDetailVO> asnDetailList = 
			asnService.getASNDetailList(1l);
		System.out.println("asnDetailList-=>"
			+JSON.toJSONString(asnDetailList));
		assertEquals(1+1, 2);
	}
	
	//showList
	@Test
	public void showList() {
		System.out.println("showList()");
		JSONObject jo1 = new JSONObject();
		try {
			String result = asnService.showList(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) { 
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
		
	}
	//addNew
	@Test
	public void addNew(){
		System.out.println("addNew()");
		JSONObject jo1 = new JSONObject();
		jo1.put("ASNID", 2);
		jo1.put("ASNNum", "2");
		jo1.put("storekey", "apple");
		jo1.put("totalPkg", 12);
		jo1.put("pkgType", "BOX");
		jo1.put("bussNum", "FA5488");
		jo1.put("InvoiceNum", "54854655");
		jo1.put("remark1", "DFA");
		jo1.put("remark2", "fafag");
		jo1.put("remark3", "fewfa");
		jo1.put("remark4", "33235");
		jo1.put("remark5", "423553");
		jo1.put("remark6", "adfad");
		jo1.put("status", "N");
		try {
			String result = asnService.addNew(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	//update
	@Test
	public void update() {
		System.out.println("update");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		try {
			String result = asnService.selectById(jo1);
			JSONObject jo2 = JSON.parseObject(result);
			
			result = asnService.update(jo2);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}

		assertEquals(1+1, 2);
	} 
	//delete
	public void delete() {
		System.out.println("delete");
		JSONObject jo1 = new JSONObject();
		jo1.put("id",2);
		
		try {
			String result = asnService.delete(jo1);
			System.out.println("result-=>"+result); 
		} catch (Exception e) { 
			e.printStackTrace();
		}

		assertEquals(1+1, 2);
	}
	//selectById
	@Test
	public void selectById() {
		System.out.println("selectById");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		try {
			String result = asnService.selectById(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	@Test
	public void selectDetailById() {
		System.out.println("selectDetailById()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		try {
			String result = asnService.selectDetailById(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) { 
			e.printStackTrace();
		}
		assertEquals(1+1, 2);
	}
	
	@Test
	public void showDetailList() {
		System.out.println("showDetailList()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 1);
		try {
			String result = asnService.showDetailList(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) { 
			e.printStackTrace();
		}
		assertEquals(1+1, 2); 
	}
	
	@Test
	public void addNewDetail() {
		System.out.println("addNewDetail()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", "7");
		jo1.put("ASNNum", "0007");
		jo1.put("seq", "1");
		jo1.put("itemNo", "1");
		jo1.put("sku", "afda");
		jo1.put("skuCN", "fewf");
		jo1.put("skuEN", "dfae");
		jo1.put("legalUnit", "1");
		jo1.put("moqNum", "2");
		jo1.put("locID", "afd");
		jo1.put("lotID", "fadf");
		jo1.put("remark1", "adfd");
		jo1.put("remark2", "efwf");
		jo1.put("remark3", "1234");
		jo1.put("remark4", "432");
		jo1.put("remark5", "534");
		jo1.put("remark6", "af32f");
		
		try {
			String result = asnService.addNewDetail(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}

		assertEquals(1+1, 2); 
	}
	
	@Test
	public void selectDetailByDid() {
		System.out.println("selectDetailByDid()");
		JSONObject jo1 = new JSONObject();
		jo1.put("did", 14);
		try {
			String result = asnService.selectDetailByDid(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}		
		assertEquals(1+1, 2); 
	}
	
	
	@Test
	public void updateDetail() {
		System.out.println("updateDetail()");
		JSONObject jo1 = new JSONObject();
		jo1.put("did", 14);
		try {
			String result = asnService.selectDetailByDid(jo1);
			JSONObject jo2 = JSON.parseObject(result);
			jo2.put("remark1", "zzzzzz");
			jo2.put("remark2", "vvvvvv");
			jo2.put("remark3", "eeee");
			result = asnService.updateDetail(jo2);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		assertEquals(1+1, 2); 
	}
	
	@Test
	public void deleteDetail() {
		System.out.println("deleteDetail()");
		JSONObject jo1 = new JSONObject();
		jo1.put("did", 14);
		
		try {
			String result = asnService.deleteDetail(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}

		assertEquals(1+1, 2); 
	}
	
	//上架分配库位
	
	//完成收货
	@Test
	public void finishASNReceive(){
		System.out.println("finishASNReceive()");
		JSONObject jo1 = new JSONObject();
		jo1.put("id", 2);		
		try {
			String result = asnService.finishASNReceive(jo1);
			System.out.println("result-=>"+result);
		} catch (Exception e) {
			e.printStackTrace();
		}		
		assertEquals(1+1, 2); 
	}
}
